package com.hejjon.service.impl;

import com.hejjon.dao.IXStudentRepository;
import com.hejjon.entity.XStudent;
import com.hejjon.service.IXStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by caoshi at 6:22 2021-08-22
 */
@Service
public class XStudentServiceImpl implements IXStudentService {

    @Autowired
    private IXStudentRepository studentRepository;

    @Override
    public List<XStudent> listBySort(Sort sort) {
        return studentRepository.findAll(sort);
    }

    @Override
    public boolean save(XStudent student) {
        if (studentRepository.existsById(student.getId())) {
            return false;
        }
        studentRepository.save(student);
        return true;
    }
}
